<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>抵押外派流程</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
    <div class="Wrapper">
        <form id="capPayInfo_form">
            <div class="fieldset1 tabel_col clearFix">
                <div class="caption">
                    <span class="title">项目发起人信息</span>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">客户经理</div>
                    <div class="field">
                        <span id="cstMgrNm" name="cstMgrNm">&nbsp;${prjBscInfoVO.cstMgrNm}</span>
                        <input type="hidden" name="cstMgrId" id="cstMgrId" value="${prjBscInfoVO.cstMgrId}"/>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">所属机构</div>
                    <div class="field">
                        <span name="cstMgrOrgCdNm" id="cstMgrOrgCdNm">&nbsp;${prjBscInfoVO.cstMgrOrgCdNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">联系方式</div>
                    <div class="field">
                        <span name="cstMgrMp" id="cstMgrMp">&nbsp;${cstMgrMp}</span>
                    </div>
                </div>
                <div class="caption">
                    <span class="title">承租人信息</span>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">承租人姓名</div>
                    <div class="field">
                        <a href="javascript:showCustomerDetail()" class="link">
                            <span name="cstNm" id="cstNm">&nbsp;${prjBscInfoVO.cstNm}</span>
                        </a>
                        <input type="hidden" id="cstId" name="cstId" value="${prjBscInfoVO.cstId}">
                        <input type="hidden" id="cstTypCd" name="cstTypCd" value="${cstTypCd}">
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">联系方式</div>
                    <div class="field">
                        <span name="mp" id="mp">&nbsp;${mp}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">身份证号码</div>
                    <div class="field">
                        <span name="certNo" id="certNo">&nbsp;${certNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_66">
                    <div class="label">通讯地址</div>
                    <div class="field">
                        <span name="postAddr" id="postAddr">&nbsp;${postAddr}</span>
                    </div>
                </div>
                <div class="fieldBox col_50" id="licRgnInfo" style="display: none">
                    <div class="label">上牌地</div>
                    <div class="field">
                        <jsp:include page="../../system/sysRegion/region.jsp" flush="true">
                            <jsp:param name="regionShowLvl"  value="2"/>
                        </jsp:include>
                        <span class="requiredSymbol">*</span>
                        <c:if test="${isDyExpBiz == '3'}">
                            <span id="saveLicRgn" class="sq-button sq-button-round" onclick="saveLicRgn();">保存上牌地</span>
                        </c:if>
                    </div>
                </div>
                <div class="caption">
                    <span class="title">项目信息及产品政策</span>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合同编号</div>
                    <div class="field">
                        <a href="javascript:toPrjDetail()" class="link">
                            <span name="lsCntNo" id="lsCntNo">&nbsp;${prjBscInfoVO.lsCntNo}</span>
                        </a>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">项目类型</div>
                    <div class="field">
                        <span name="prjTypCdNm" id="prjTypCdNm">&nbsp;${prjBscInfoVO.prjTypCdNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">业务类型</div>
                    <div class="field">
                        <span name="bizTypCdNm" id="bizTypCdNm">&nbsp;${prjBscInfoVO.bizTypCdNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">金融机构</div>
                    <div class="field">
                        <span name="fundRasInsNm" id="fundRasInsNm">&nbsp;${prjBscinfoVO.fundRasInsNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合同总金额</div>
                    <div class="field">
                        <span name="contAmt" id="contAmt">&nbsp;${contAmt}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">融资总金额</div>
                    <div class="field">
                        <span name="actLsAmt" id="actLsAmt">&nbsp;${actLsAmt}</span>
                    </div>
                </div>
                <div class="caption">
                    <span class="title">项目产品信息</span>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <span name="paySchNo" id="paySchNo">&nbsp;${paySchNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">车架号</div>
                    <div class="field">
                        <span name="vin" id="vin">&nbsp;${vin}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">车辆型号</div>
                    <div class="field">
                        <span name="prdMdl" id="prdMdl">&nbsp;${prdMdl}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">发动机号</div>
                    <div class="field">
                        <span name="engNo" id="engNo">&nbsp;${engNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">挂靠公司名称</div>
                    <div class="field">
                        <a href="javascript:showPrjLnkComp()" class="link">
                            <span name="lnkCompNm" id="lnkCompNm">&nbsp;${lnkCompNm}</span>
                        </a>
                    </div>
                </div>

                <div class="caption" id="assignInfo" style="display: none">
                    <span class="title">指派人员信息</span>
                </div>
                <div class="fieldBox col_50" id="areaMgrInfo" style="display: none">
                    <div class="label">区域经理</div>
                    <div class="field">
                        <input name="areaMgrId" id="areaMgrId" type="hidden" value="${areaMgrId}" />
                        <input name="areaMgrUsrNm" id="areaMgrUsrNm" type="hidden" value="${areaMgrUsrNm}" />
                        <input name="areaMgrNm" id="areaMgrNm" type="text" class="ui-textbox" disabled value="${areaMgrNm}" />
                        <span id="areaMgrSpan" class="requiredSymbol" style="display: none">&nbsp;*</span>
                        <span id="selectAreaMgrBtn" class="sq-button sq-button-round" onclick="setAssigneeRow(1)">选择</span>
                    </div>
                </div>
                <div class="fieldBox col_50" id="realMgrInfo" style="display: none">
                    <div class="label">抵押人</div>
                    <div class="field">
                        <input name="mortgageMgrId" id="mortgageMgrId" type="hidden" value="${mortgageMgrId}" />
                        <input name="mortgageMgrUsrNm" id="mortgageMgrUsrNm" type="hidden" value="${mortgageMgrUsrNm}" />
                        <input name="mortgageMgrNm" id="mortgageMgrNm" type="text" class="ui-textbox" disabled value="${mortgageMgrNm}" />
                        <span id="mortgageMgrSpan" class="requiredSymbol" style="display: none">&nbsp;*</span>
                        <span id="selectMortgageMgrBtn" class="sq-button sq-button-round" onclick="setAssigneeRow(3)">选择</span>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <script type="text/javascript">

        var prjPrdGrid = null;
        var _prjPrdDtlId = '${prjPrdDtlId}';
        var _prjId = '${prjId}';
        var _lnkCompId = '${lnkCompId}';
        //1.随州后台(选择区域经理)  2.区域经理(选择抵押人) 3.抵押人(选择上牌地)  0.其余(仅可查看)
        var _isDyExpBiz = '${isDyExpBiz}';
        var _id = '${id}';//抵押外派人员记录表id

        $(function () {
            initData();
        });

        function initData() {
            $("#capPayInfo_form").ligerForm({
                validate: true
            });
            disabledInput();
            //设置省、市
            setRgnProvCdUpdataValue('${licRgnPrCd}');
            setRgnCityCdUpdataValue('${licRgnCyCd}');
        }

        function disabledInput() {
            if (_isDyExpBiz == 1){
                $("#areaMgrInfo").removeAttr("style");
                $("#areaMgrSpan").removeAttr("style");
                $("#assignInfo").removeAttr("style");
                $("#selectAreaMgrBtn").show();
            } else if (_isDyExpBiz == 2){
                $("#realMgrInfo").removeAttr("style");
                $("#mortgageMgrSpan").removeAttr("style");
                $("#assignInfo").removeAttr("style");
                $("#selectMortgageMgrBtn").show();
            } else if (_isDyExpBiz == 3){
                $("#licRgnInfo").removeAttr("style");
            } else {
                $("#licRgnInfo").removeAttr("style");
                if (liger.get("rgnProvCd") && liger.get("rgnCityCd")){
                    liger.get("rgnProvCd").setDisabled();
                    liger.get("rgnCityCd").setDisabled();
                }
            }
        }


        //保存上牌信息
        function saveLicRgn(){

            var rgnPrCd = getRgnProvCd();//居住地省
            var rgnCyCd = getRgnCityCd();//居住地市
            if (!_id || _id == ''){
                top.$.ligerDialog.SQalert({content: "无客户经理（外地）信息，请联系管理员.", SQ_type: "warning"});
                return;
            }
            if(!rgnPrCd || rgnPrCd=="" || !rgnCyCd || rgnCyCd=="" ){
                top.$.ligerDialog.SQalert({content: "上牌地省、市不能为空.", SQ_type: "warning"});
                return;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                data:{
                    id: _id,
                    licRgnPrCd: rgnPrCd,
                    licRgnCyCd: rgnCyCd
                },
                url: '<%=path%>/expatriate/expBizManRec/saveDyLicExpBizManRec.do',
                beforeSend: function(){
                    wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    }else{
                        top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        }

        //项目详情
        function toPrjDetail() {
            if (!_prjId)return;
            Add_navTab("prjDetail" + _prjId, "项目信息", '<%=path%>/project/prjbscinfo/toModifyPage.do?detailFlag=true&id=' + _prjId);
        }

        //承租人详情
        function showCustomerDetail(){
            var _cstId = '${prjBscInfoVO.cstId}';
            var _cstTypCd = '${cstTypCd}';
            if(!_cstId || !_cstTypCd) return;
            if(_cstTypCd == 1){
                Add_navTab('tab_customer_np_detail'+_cstId,'承租人详情','<%=path%>/customer/cstbscinfo/toCustCstBacInfoNpDetailPage.do?id='+_cstId);
            }else if(_cstTypCd == 2){
                Add_navTab('tab_customer_corp_detail'+_cstId,'承租人详情','<%=path%>/customer/cstbscinfo/toCustCstBacInfoCorpDetailPage.do?id='+_cstId);
            }
        }
        //挂靠公司详情
        function showPrjLnkComp(){
            if (!_lnkCompId) return ;
            Add_navTab('tab_prj_lnk_comp_detail' + prjLnkCompId, '挂靠公司详情', '<%=path%>/project/prjlnkcomp/toDetailPage.do?id=' + _lnkCompId);
        }
        //跳转选择经理页面
        function setAssigneeRow(mgrType) {
            var This_dialog = $.ligerDialog.SQopen({
                url: "<%=path%>/flow/flow/toChooseUsrWinPageDialog.do?isMore=0&mgrType=" + mgrType + "&dataId=" + _prjPrdDtlId + "&dataTypCd=DTL",
                width: 1000,
                title: "选择组织用户",
                onClosed: function () {
                    if (!This_dialog._DATA.usrIds || This_dialog._DATA.usrIds.length == 0) {
                        //没有选择任何人说明是关闭了窗口
                    } else {
                        if (This_dialog._DATA.usrIds.length > 1) {
                            top.$.ligerDialog.SQalert({content:"只能选择一个用户!", SQ_type: "error"});
                            return;
                        } else {
                            var userInfo = This_dialog.get("_usrs");
                            var userId = "";
                            var userName = "";
                            var realName = "";
                            for (var k in userInfo[0]) {
                                userId = k;
                                userName = userInfo[0][k].usrNm;
                                realName = userInfo[0][k].rlNm;
                            }
                            // 保存
                            $.ajax({
                                type: 'post',
                                dataType: 'json',
                                data: {
                                    prjPrdDtlId: _prjPrdDtlId,
                                    aptTypCd: mgrType,
                                    dataTypCd: "DTL",
                                    usrId: userId,
                                    rlNm: realName,
                                    usrNm: userName,
                                    id: _id
                                },
                                url: '<%=path%>/expatriate/expBizManRec/saveDyLicExpBizManRec.do',
                                success:function(msg){
                                    if(msg.success == 1){
                                        if (1 == mgrType) {
                                            $("#areaMgrId").val(userId);
                                            $("#areaMgrUsrNm").val(userName);
                                            liger.get("areaMgrNm").setValue(realName);
                                        }
                                        if (3 == mgrType) {
                                            $("#mortgageMgrId").val(userId);
                                            $("#mortgageMgrUsrNm").val(userName);
                                            liger.get("mortgageMgrNm").setValue(realName);
                                        }
                                        top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                                    }else{
                                        top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                                    }
                                }
                            });
                        }
                    }
                }
            });
        }
    </script>

</body>
</html>
